package cn.com.utt.unms.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.com.utt.unms.pojo.Location;

@Mapper
public interface LocationMapper {
	
	@Insert("insert into `location`(name,province,city,district,address,lng,lat) values(#{name},#{province},#{city},#{district},#{address},#{lng},#{lat})")
	@Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
	void save(Location location);
	
	@Update("update `location` set name=#{name},province=#{province},city=#{city},district=#{district},lng=#{lng},lat=#{lat} where id=#{id}")
	void update(Location location);
	
	@Select("select * FROM `location` WHERE id=#{id}")
	Location queryLocation(@Param("id")Long id);
	
	@Select("select id FROM `location` WHERE province=#{provinceId}")
	List<Long> queryLocationByProvinceId(@Param("provinceId")Long provinceId);
	
}
